{% extends 'student_management/base.html' %}

{% block content %}
<div class="card mb-4">
    <div class="card-header">
        <h3>{{ teacher.name }} 教师评价详情</h3>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <h5>基本信息</h5>
                <p><strong>工号：</strong> {{ teacher.teacher_id }}</p>
                <p><strong>职称：</strong> {{ teacher.title }}</p>
                <p><strong>院系：</strong> {{ teacher.department }}</p>
            </div>
            <div class="col-md-6">
                <h5>评分统计</h5>
                <p><strong>平均评分：</strong> {{ avg_rating|default:'暂无评分'|floatformat:1 }} / 5.0</p>
                <p><strong>评价总数：</strong> {{ ratings.count }}</p>
            </div>
        </div>
    </div>
</div>

<div class="card">
    <div class="card-header">
        <h4>评价列表</h4>
    </div>
    <div class="card-body">
        {% if ratings %}
            {% regroup ratings by course as course_ratings %}
            {% for course_group in course_ratings %}
                <h5 class="mt-3">{{ course_group.grouper.name }}</h5>
                <div class="list-group mb-4">
                    {% for rating in course_group.list %}
                    <div class="list-group-item">
                        <div class="d-flex justify-content-between align-items-center">
                            <h6 class="mb-1">{{ rating.student.name }}</h6>
                            <div>
                                <span class="badge bg-primary">{{ rating.rating }} 分</span>
                                <small class="text-muted ms-2">{{ rating.created_at|date:"Y-m-d H:i" }}</small>
                            </div>
                        </div>
                        {% if rating.comment %}
                        <p class="mb-1">{{ rating.comment }}</p>
                        {% endif %}
                    </div>
                    {% endfor %}
                </div>
            {% endfor %}
        {% else %}
            <p class="text-center">暂无评价记录</p>
        {% endif %}
    </div>
</div>

<div class="mt-3">
    <a href="{% url 'teacher-list' %}" class="btn btn-secondary">返回教师列表</a>
</div>
{% endblock %} 